package com.boco.ibssystem.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boco.biinjectionserviceapi.vo.Params;
import com.boco.ibssystem.business.mapper.YlxwMapper;
import com.boco.ibssystem.business.service.IYlxwService;
import com.boco.ibssystem.business.vo.CountData;
import com.boco.ibssystem.business.vo.PieData;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: yichaofan
 * @date: 2019年05月13日 9:41
 * @email: hjljy@outlook.com
 * @version: v1.0
 * @description:
 */
@Service
public class IYlxwServiceImpl extends ServiceImpl<YlxwMapper, PieData>  implements IYlxwService {
    @Override
    public PieData getAllCount(Params params) {
        return baseMapper.getAllCount(params);
    }

    @Override
    public PieData getzyyfy(Params params) {
        return baseMapper.getzyyfy(params);
    }

    @Override
    public PieData getmzyfy(Params params) {
        return baseMapper.getmzyfy(params);
    }

    @Override
    public PieData getmzzy(Params params) {
        return baseMapper.getmzzy(params);
    }

    @Override
    public PieData getzycy(Params params) {
        return baseMapper.getzycy(params);
    }

    @Override
    public List<PieData> getzxzd(Params params) {
        List<PieData> data =  baseMapper.getmzzd(params);
        List<PieData> data1 =  baseMapper.getzyzd(params);
        for (PieData pieData : data1) {
            for (PieData datum : data) {
                if(datum.getName().equals(pieData.getName())){
                    if (datum.getName().equals("01")){
                        datum.setName("西医诊断量");
                    }
                    if (datum.getName().equals("02")){
                        datum.setName("中医诊断量");
                    }
                    datum.setValue(datum.getValue()+pieData.getValue());
                }
            }
        }
        return data;
    }

    @Override
    public Map<String, List<CountData>> getZdxwCountData(Params params) {
        Map<String, List<CountData>> map = new HashMap<>();
        List<CountData> topData=  baseMapper.getJbTop(params);
        List<CountData> ylyxData=  baseMapper.getYlyx(params);
        map.put("诊断疾病top10数据",topData);
        map.put("医疗影像数据",ylyxData);
        return map;
    }

    @Override
    public List<PieData> getZllbPie(Params params) {
        return baseMapper.getZllbPie(params);
    }

    @Override
    public Map<String, List<CountData>> getHzzlData(Params params) {
        Map<String, List<CountData>> map = new HashMap<>();
        List<CountData> mzData = baseMapper.getHzzlMzData(params);
        List<CountData> zyData = baseMapper.getHzzlZyData(params);
        map.put("门诊患者治疗数据",mzData);
        map.put("住院患者治疗数据",zyData);
        return map;
    }

    @Override
    public Map<String, List<PieData>> getSsxwPie(Params params) {
        Map<String, List<PieData>> map = new HashMap<>();
        List<PieData> ssjbData = baseMapper.getSsjbData(params);
        List<PieData> sslxData = baseMapper.getSslxData(params);
        map.put("手术级别数据",ssjbData);
        map.put("手术类型数据",sslxData);
        return map;
    }

    @Override
    public List<CountData> getSstjData(Params params) {
        return baseMapper.getSstjData(params);
    }
}
